# _*_coding:utf-8_*_
"""
   ATS 1.0(Automated Test Server, Version 1.0) Error Handler Module,
   Developed by Ivy.Li 2013.03.29.
   (C)Copyright 2013 Hech. All rights reserved
"""

import sys
import os


workpath = os.path.dirname(os.path.realpath(sys.argv[0]))
sys.path.insert(0, os.path.dirname(workpath))

# Err code define for EE
EXEC_UAP_ERR = 25003
EXEC_TEST_ERR = 25002

# EE err code define for EEM
INVAL_EE_CONFIG = 25100
ALL_EES_FAILED = 25101

## err code define for execute ptm test
ADDGDATA_ERR = 21000
PTM_POSTERR = 21001

# Define the error area in which is not so important that can be ignored
IGNORE_ERR_BEGIN = 20001
IGNORE_ERR_END = 22000

# Define FATAL error, which will stop test when the error occured
FATAL_ERR_BEGIN = 25001
FATAL_ERR_END = 26000

DEBUG_INFO = 20002
INIT_PYVISA_ERR = 20003


def can_ignore(err_code):
    if err_code:
        if IGNORE_ERR_BEGIN <= err_code <= IGNORE_ERR_END:
            return True
        else:
            return False


def handle_err(who, err_code, err_msg,level="error"):
    """
	Currently, handle error means myLog it to file.
	"""
    logger.get_logger().add2msgQ(who, err_code, err_msg, level)
